package com.ruoyi.system.service.impl;

import com.alibaba.csp.sentinel.util.AssertUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.domain.bm.BMPack;
import com.ruoyi.system.mapper.BaseBannerMapper;
import com.ruoyi.system.mapper.bm.BMPackMapper;
import com.ruoyi.system.service.IBaseBMPackService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class BaseBMPackServiceImpl extends ServiceImpl<BMPackMapper, BMPack> implements IBaseBMPackService
{

    @Resource
    TokenService tokenService;

    @Override
    public List<BMPack> selectList(BMPack dto) {
        return baseMapper.selectByList(dto);
    }

    @Override
    public boolean insert(BMPack dto) {
        AssertUtil.notNull(dto.getName(),"名称不能为空");
        AssertUtil.notNull(dto.getLogo(),"图片不能为空");
        AssertUtil.notNull(dto.getContestId(),"联赛不能为空");
        AssertUtil.notNull(dto.getAmount(),"金额不能为空");
        dto.setCreateTime(new Date());
        return save(dto);
    }

    @Override
    public boolean modify(BMPack dto) {
        AssertUtil.notNull(dto.getId(),"id不能为空");
        dto.setUpdateTime(new Date());
        return updateById(dto);
    }
}
